home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / mindos11.zip / MDISK.C < prev    next >
C/C++ Source or Header  |  1991-03-22  |  3KB  |  110 lines

  1. /*  mdisk.c   -- Display a disk's physical attributes */
  2. /*  Copyright 1991, Steven W. Harrold - All rights reserved */
  3. /*  $Header: MDISK.C_V 1.2 91/03/22 07:54:13 SWH Exp $ */
  4.  
  5. #include    <stdio.h>
  6. #include    <stdlib.h>
  7. #include    <ctype.h>
  8. #include    <stddef.h>
  9. #include    "mfs.h"
  10. #include    "dev.h"
  11.  
  12. DEVINIT
  13.  
  14.  
  15. /*==================================================================*/
  16. int main(argc, argv)
  17. int     argc ;
  18. char    *argv[] ;
  19. {
  20.     char            drive_id ;
  21.     int             drive ;
  22.     int             sides = 0 ;
  23.     struct devdata  *dp ;
  24.  
  25.     printf ("**** Displays physical attributes of a disk/drive ****\n") ;
  26.     printf ("\n") ;
  27.  
  28. /*  Does he want help?
  29.  */
  30.     if ((argc >= 2) && (argv[1][0] == '-') && (argv[1][1] == '?'))
  31.     {
  32. printf ("Copyright 1988,1991 Steven W. Harrold - All rights reserved\n") ;
  33.         printf ("Version %s\n", VERSION) ;
  34.         printf ("Usage:   %s  [[drid] sides]\n", argv[0]) ;
  35.         printf ("'drid' is a letter from the set [a-z], default: 'a'\n") ;
  36.         printf ("'sides' is number of heads for single sided floppy\n");
  37.         exit (0) ;
  38.     }
  39.  
  40. /*  Obtain the floppy identifier (if alphabetic) or hard drive
  41. **  identifier (if numeric).  Default is A:.
  42. */
  43.     if (argc == 1)
  44.         drive_id = 'A' ;
  45.     else
  46.     {
  47.         drive_id = argv[1][0] ;
  48.         drive_id = toupper(drive_id) ;
  49.     }
  50.  
  51.     if (isalpha(drive_id))
  52.         drive = drive_id - 'A' ;
  53.     else if (isdigit(drive_id))
  54.         drive = 0x80 + (drive_id - '0') ;
  55.     else
  56.     {
  57.         printf ("Drive '%c' must be alphanumeric\n", drive_id) ;
  58.         return -1 ;
  59.     }
  60.  
  61. /*  Obtain the sides count, if supplied
  62. */
  63.     if (argc > 2)
  64.         sides = atoi (argv[2]) ;
  65.  
  66. /*  Initialize the device data block
  67. */
  68.     printf ("Using drive=0x%02X and sides=%d\n", drive, sides) ;
  69.  
  70.     dp = devinit (drive, sides) ;
  71.     if (!dp)
  72.     {
  73.         printf ("The devdata block was not allocated; Dstatus=%d\n",
  74.                 Dstatus) ;
  75.         return -1 ;
  76.     }
  77.     printf ("Status from devinit() = %d\n", dp->d_status) ;
  78.     if (dp->d_status)
  79.         return dp->d_status ;
  80.  
  81. /*  Display the results
  82. */
  83.     printf ("Tracks............ %d\n",   dp->d_tracks    ) ;
  84.     printf ("Heads............. %d\n",   dp->d_heads     ) ;
  85.     printf ("Sectors........... %d\n",   dp->d_sectors   ) ;
  86.     printf ("Interleave........ %d:1\n", dp->d_interleave) ;
  87.     printf ("Partition offset.. %d\n",   dp->d_partoff   ) ;
  88.  
  89.     if ((dp->d_heads==1) && (dp->d_tracks==40) && (dp->d_sectors== 8))
  90.         printf ("160KB  SSSD/8 5.25\" disk\n") ;
  91.     if ((dp->d_heads==2) && (dp->d_tracks==40) && (dp->d_sectors== 8))
  92.         printf ("320KB  DSSD/8 5.25\" disk\n") ;
  93.     if ((dp->d_heads==2) && (dp->d_tracks==40) && (dp->d_sectors== 9))
  94.         printf ("360KB  DSSD 5.25\" disk\n") ;
  95.     if ((dp->d_heads==2) && (dp->d_tracks==80) && (dp->d_sectors== 9))
  96.         printf ("720KB  DSSD/80 5.25\" disk\n") ;
  97.     if ((dp->d_heads==2) && (dp->d_tracks==80) && (dp->d_sectors==15))
  98.         printf ("1.2MB  DSDD 5.25\" disk\n") ;
  99.     if ((dp->d_heads==2) && (dp->d_tracks==80) && (dp->d_sectors== 9))
  100.         printf ("720KB  DSSD 3.5\" disk\n") ;
  101.     if ((dp->d_heads==2) && (dp->d_tracks==80) && (dp->d_sectors==18))
  102.         printf ("1.4KB  DSDD 3.5\" disk\n") ;
  103.  
  104.     return 0 ;
  105.  
  106. } /* main() */
  107.  
  108.  
  109. /*---eof---*/
  110.